package com.lyb.springbootredisclient.app.sattagy;

import com.google.common.collect.Lists;

import java.util.List;
import java.util.function.Consumer;

/**
 * 批量SQL处理工具类
 *
 * @author zhangjingyi
 */
public class InsertSqlUtils {

    public static  <T> void batchInsertData(Consumer<List<T>> consumer,
                                            List<T> paramList,
                                            int batchSize) {
        List<List<T>> partition = Lists.partition(paramList, batchSize);
        for (List<T> ts : partition) {
            consumer.accept(ts);
        }
    }
}
